#!/usr/bin/env python
import sys
import helper
import class_set
from sets import Set

class FollowFriendRecommendationReasonReducer(helper.ReducerHelper):

    def processor(self, key, lst):
        tm = 0
        for e in lst:
            left, right = self.split(e)
            if left is None:
                tm = int(e)
                break
        else:
            return

        for e in lst:
            left, right = self.split(e)
            if left is None:
                continue
            recom_tag = class_set.RecomTag('')
            recom_tag.init(right)
            if recom_tag.isType('friend') or recom_tag.isType('follow'):
                recom_tag.setTime(tm)
            self.allocator(self.join(left, key), recom_tag)


def main():
    ffrrr = FollowFriendRecommendationReasonReducer()
    ffrrr.reducer()

if __name__ == '__main__':
    main()

